#include <bits/stdc++.h>
#include "../../tools/tools.h"
using namespace std;

constexpr int INF = 0x7fffffff; // 无穷大
typedef long long ll;

class Solution {
public:
    int maxTotalReward(vector<int>& rewardValues) {
        set<int> s(rewardValues.begin(), rewardValues.end());
        vector<int> arr(s.begin(), s.end());
        int N = 100005;
        bitset<100005> sum;
        sum[0] = true;
        for (auto& x : arr) {
            sum |= sum << (N - x) >> (N - x) << x;
        }
        int ans = 0;
        for(int i = 0; i < N; i++) {
            if(sum[i]) ans = i;
        }
        return ans;
    }
};

int main(int argc, char* argv[]) {
    Solution s;
    vector v = {10, 3, 15, 4};
    debug(s.maxTotalReward(v));
    // v = {1, 6, 4, 3, 2};
    // debug(s.maxTotalReward(v));
}
